//
// List groups
// --------------------------------------------------

// Individual list items
//
// Use on `li`s or `div`s within the `.list-group` parent.

.list-group-item {
  color: $gray-darker;
  background-color: $list-group-bg;
  border: 1px solid $list-group-border;

  // Round the first and last items
  &:first-child {
    @include border-top-radius($list-group-border-radius);
  }

  &:last-child {
    @include border-bottom-radius($list-group-border-radius);
  }

  .dropdown {
    display: none;
  }

  .dropdown-toggle {
    display: inline-block;
    padding: 5px 6px 5px 5px;
    color: $gray-darker;
  }
}

// Linked list items
//
// Use anchor elements instead of `li`s or `div`s to create linked list items.
// Includes an extra `.active` modifier class for showing selected items.

a.list-group-item {
  color: $list-group-link-color;

  .list-group-item-heading {
    color: $list-group-link-heading-color;
  }
}

.list-group-item {
  // Active class on item itself, not parent
  &.active,
  &.active:hover,
  &.active:focus {
    font-weight: bold;
    color: $list-group-active-color;
    background-color: $list-group-active-bg;
    border-color: $list-group-active-border;
    border-left: 4px solid $list-group-active-color;
    border-left-color: $list-group-active-color;

    .list-group-item-text {
      font-weight: normal;
      color: $list-group-active-text-color;
    }
  }

  &.active:hover,
  &.active:focus {
    background-color: $list-group-hover-bg;
  }
}

a.list-group-item,
li.list-group-item a {
  // Hover state
  &:hover,
  &:focus {
    color: $list-group-link-hover-color;
    text-decoration: none;
    background-color: $list-group-hover-bg;
  }
}

li.list-group-item {
  padding: 0;
  margin-bottom: 0;
  border: 0 none;

  > a {
    display: block;
    padding: $padding-base-vertical 17px;
    margin: 0 0 0 14px;
    color: $gray-darker;
  }

  &.active,
  &.active:hover,
  &.active:focus {
    background-color: $list-group-active-bg;

    > a {
      margin-left: 10px;
      color: $list-group-active-color;
    }
  }
}

// Contextual variants
//
// Add modifier classes to change text and background color on individual items.
// Organizationally, this must come after the `:hover` states.

@include list-group-item-variant(success, $state-success-bg, $state-success-text);
@include list-group-item-variant(info, $state-info-bg, $state-info-text);
@include list-group-item-variant(warning, $state-warning-bg, $state-warning-text);
@include list-group-item-variant(danger, $state-danger-bg, $state-danger-text);

// List group item wrapper
// -------------------------

.list-group-item-wrapper {
  margin-left: 14px;

  &:hover > .dropdown {
    display: block;
  }

  > a {
    display: block;
    padding: 5px 17px;
    margin: 0;
    color: $gray-darker;
    // &:hover {
    //   background-color: $gray-lighter !important;
    // }
  }

  > .dropdown {
    &:hover + a {
      background-color: $gray-lighter;
    }

    &.open {
      display: block;

      + a {
        background-color: $gray-lighter;
      }
    }

    > .dropdown-menu {
      margin-top: 0;
    }
  }
}

// List group headers
// -------------------------

.list-group-header {
  display: block;
  padding: 10px 30px 10px 15px;
  font-size: 11px;
  font-weight: bold;
  line-height: $line-height-base;
  color: $gray-light;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
  text-transform: uppercase;

  @at-root {
    li#{&} {
      padding: 3px 15px;
    }
  }

  .list-group & {
    margin-top: 9px;
  }
}

li.list-group-header {
  padding: 3px 15px;
}

// Collapsible menu
.list-group-item-menu {
  @include box-shadow(none);
  // No need to set list-style: none; since .list-group-item is block level
  padding: 0;
  margin: 0;
  border: 0 none;
  border-radius: 0;

  .list-group-item-wrapper > a {
    padding-left: 30px;
  }

  .list-group-item-menu .list-group-item-wrapper > a {
    padding-left: 44px;
  }

  > .list-group-item {
    .collapse-caret {
      margin-left: 28px;
    }
  }
}

// Caret
.collapse-caret {
  position: absolute;
  z-index: 1;
  display: inline-block;
  width: 17px;
  height: 28px;
  margin-left: 14px;

  &::before {
    @extend .caret;
    position: absolute;
    top: 12px;
    left: 5px;
    margin-left: 0;
    content: "";
    border-bottom: 0 dotted;
  }

  &:hover {
    background-color: $gray-lighter;
  }

  &.collapsed::before {
    @extend .caret-right;
    top: 10px;
    left: 6px;
  }
}

// Dividers (basically an hr) within the list group
.list-group .divider {
  @include nav-divider();
  margin-right: 15px;
  margin-left: 15px;
}
